# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Fabio Ribeiro <fabiorphp@gmail.com>
pkgname=php7-pecl-msgpack
_pkgreal=msgpack
pkgver=2.1.1
pkgrel=0
pkgdesc="PHP extension provides API for communicating with MessagePack serialization - PECL"
url="https://pecl.php.net/package/msgpack"
arch="all"
license="BSD-3-Clause"
depends="php7-session php7-sockets"
makedepends="php7-dev autoconf re2c"
source="https://pecl.php.net/get/$_pkgreal-$pkgver.tgz
	https://github.com/msgpack/msgpack-php/pull/152.patch"
builddir="$srcdir"/$_pkgreal-$pkgver
provides="php7-msgpack=$pkgver-r$pkgrel" # for backward compatibility
replaces="php7-msgpack" # for backward compatibility

build() {
	phpize7
	./configure --prefix=/usr --with-php-config=php-config7
	make
}

check() {
	rm -f tests/034.phpt # https://github.com/msgpack/msgpack-php/issues/136
	rm -f tests/035.phpt # may fail in a slow environment https://github.com/msgpack/msgpack-php/issues/123
	# Tests require session and sockets extensions which are not bundled
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test PHP_TEST_SHARED_EXTENSIONS="
		-d extension=/usr/lib/php7/modules/session.so \
		-d extension=/usr/lib/php7/modules/sockets.so \
		-d extension=modules/$_pkgreal.so"
}

package() {
	make INSTALL_ROOT="$pkgdir"/ install
	install -d "$pkgdir"/etc/php7/conf.d
	echo "extension=$_pkgreal.so" > "$pkgdir"/etc/php7/conf.d/50_$_pkgreal.ini
}

sha512sums="dffa21e36ac8bafa076557093e0bca70772e810215900ce0f9c0e0cc6f4f5aac567178c9bb6c5f962bdda11139d03bc9004f85d9e0a58acf181ef8959e953281  msgpack-2.1.1.tgz
88bbe2b499dc9eb1b28ca3cfc520af60f8b2c306361e20daa5242f61fe8c93825c0bdf75ad52fb35d5d19304b577fbaaaa1d8c044b17de078d4c59fb1731b38b  152.patch"
